let babel = require('babel-core');
let types = require('babel-types');
const visitor = {
    BinaryExpression(path){
        let node = path.node;
        if(!types.isBinaryExpression(node))return;
        let result;
        let left = node.left;
        let right = node.right;
        if(!(isNaN(left.value) || isNaN(right.value))){
            result = eval(left.value+node.operator+right.value);
            path.replaceWith(types.numericLiteral(result));
            let parent = path.parentPath;
            parent && visitor.BinaryExpression.call(this,parent);
        }
    }
}
module.exports = function(babel){
    return {
        visitor
    }
}